package com.jianzh5.listener;

import com.jianzh5.service.SysConfigServiceI;
import com.jianzh5.util.InfoCenterHome;
import com.sun.istack.internal.logging.Logger;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletContext;
import java.util.ResourceBundle;

/**
 * 读取系统配置文件 properties
 */
public class SystemConfigStarter implements Starter{
    private static final Logger logger = Logger.getLogger(SystemConfigStarter.class);
    private static final ResourceBundle bundle = ResourceBundle.getBundle("webConfig");

    @Override
    public void updateCache(ServletContext sc) {
        WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(sc);
        SysConfigServiceI sysConfigServiceImpl;
        if(context != null){
            sysConfigServiceImpl = (SysConfigServiceI) context.getBean("sysConfigService");
        }else{
            logger.severe("获取应用程序上下文失败...");
            System.out.println("获取应用程序上下文失败...222");
            return;
        }
        logger.info("初始化系统参数");
        if(InfoCenterHome.homeConfig.isEmpty()){
            initConfig();
        }
    }

    private void initConfig() {

    }
}
